<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>文章列表--layui后台管理模板 2.0</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="format-detection" content="telephone=no">
		<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
		<link rel="stylesheet" href="../../css/public.css" media="all" />
	</head>

	<body class="childrenBody">
		<form id="form0" action="http://127.0.0.1:88/index.php/shop/shop/shopEdit" class="layui-form" style="width:80%;">
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">店铺名称</label>
				<div class="layui-input-block">
					<input id="shop_img_url" type="hidden" class="shop_img_url" value="" lay-verify="shop_img_url" name="shop_img_url" />
					<input id="user_name" type="hidden" name="user_name" />
					<input id="shop_id" type="hidden" name="shop_id" />
					<input type="text" name="shop_name" class="layui-input shop_name" lay-verify="required" placeholder="请输入店铺名称">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">旺旺号</label>
				<div class="layui-input-block">
					<input type="text" name="shop_wangwang" class="layui-input shop_wangwang" lay-verify="required" placeholder="请输入旺旺号">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">店铺类型</label>
				<div class="layui-input-block">
					<input type="radio" name="shop_type" value="淘宝" title="淘宝" checked>
					<input type="radio" name="shop_type" value="京东" title="京东">
					<input type="radio" name="shop_type" value="拼多多" title="拼多多">
					<input type="radio" name="shop_type" value="阿里巴巴" title="阿里巴巴">
				</div>
			</div>
			<div class="layui-form-item layui-row layui-col-xs12">
				<label class="layui-form-label">店铺截图</label>
				<div class="layui-input-inline">
					<div class="layui-upload">
					  <button type="button" class="layui-btn" id="test1">上传图片</button>
					  <div class="layui-upload-list">
					  	<img src="" alt="示例" class="shop_img" id="shili" width="50%" style="display: block;" />
					    <img class="layui-upload-img" width="50%" id="demo1">
					    <p id="demoText"></p>
					  </div>
					</div>  
				</div>
			</div>
			<!--<div class="layui-form-item">
				<label class="layui-form-label">店铺截图</label>
				<div class="layui-input-inline">
					<input id="photoCover" class="layui-input layui-disabled" required lay-verify="photoCover" name="photoCover" readonly type="text">
				</div>
				<div class="layui-form-mid layui-word-aux">
					<label class="input-group-btn">
			    	<input id="file" type="file" name="file" required lay-verify="required" style="left: -9999px; position: absolute;">
			        <span type="button" class="layui-btn layui-btn-normal btn btn-default" id="test8" style="margin-top: -10px;">选择文件</span>
			    </label>
				</div>
			</div>
			<div class="layui-form-item shili" style="display: none;">
				<label class="layui-form-label">示例截图</label>
				<div class="layui-input-block">
					<img src="../../images/alipay.jpg" />
				</div>
			</div>
			<div class="layui-form-item yulan" style="display: none;">
				<label class="layui-form-label">图片预览</label>
				<div class="layui-input-block">
					<img src="" width="50%" name="imgview" id="imgview" />
				</div>
			</div>-->
			<div class="layui-form-item layui-row layui-col-xs12">
				<div class="layui-input-block">
					<button id="addShop" class="layui-btn layui-btn-sm" lay-submit="" lay-filter="addShop">立即添加</button>
					<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary">取消</button>
				</div>
			</div>
		</form>
		<script type="text/javascript" src="../../layui/layui.js"></script>
		<script src="../../js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="shopEdit.js"></script>
		<script type="text/javascript">
			layui.use(['form', 'layer', 'laydate', 'table', 'laytpl'], function() {
				var form = layui.form,
					layer = parent.layer === undefined ? layui.layer : top.layer,
					$ = layui.jquery,
					laydate = layui.laydate,
					laytpl = layui.laytpl,
					table = layui.table,
					laypage = layui.laypage;
					$("#shili").show();
					$("#user_name").val(localStorage.login_name);

				//添加验证规则
				form.verify({
					
					/*shop_img_url:function(value){
						if(value == "") {
							return "请选择广告图片";
						}
					}*/
				});
				
				/*form.on("submit(addShop)",function(){
					var formData=new FormData($("#form0")[0]);
					console.log(formData);
					$.ajax({
						url:"http://127.0.0.1:88/index.php/shop/shop/addShop?id="+formData,
						type:"post",
						//cache: false, //上传文件不需要缓存
					    //data: data.feild,
					    //processData: false, // 此处是关键：告诉jQuery不要去处理发送的数据
					    //contentType: false, // 此处是关键：告诉jQuery不要去设置Content-Type请求头
					    success:function(res){
					    	alert("11");
					    },
					    error:function(res){
					    	alert("22");
					    }
					});
				})*/
				
				/*$("#addShop").click(function(){
					parent.location.reload();
				})*/
				
				//当店铺名失去焦点的时候，判断店铺名是否存在
				/*$(".shop_name").blur(function(){
					$.ajax({
						type:"post",
						url:"http://127.0.0.1:88/index.php/shop/shop/isShop?id="+$(".shop_name").val(),
						success:function(data){
							if(data.code==200){
								layer.msg(data.msg);
								$(".shop_name").focus();
							}
							
						}
					});
				})*/
			})
			//图片预览
			$(function() {
				$(".shili").show();
				$("#file").change(function(e) {
					var file = e.target.files[0] || e.dataTransfer.files[0];
					$('#photoCover').val(document.getElementById("file").files[0].name);
					if(file) {
						var reader = new FileReader();
						reader.onload = function() {
							$("#imgview").attr("src", this.result);
							$(".shili").hide();
							$(".yulan").show();
						}

						reader.readAsDataURL(file);
					}
				});
			})
			
		</script>
	</body>

</html>